// 用户相关类型定义
export interface User {
  token: string;
  id: number;
  user_type: number;
  name: string;
  email: string;
  avatar?: string;
  created_at: string;
  updated_at: string;
  follow_flag: number;
  uid: number;
  u_counter: {
    followings_count: number;
    fans_count: number;
    likes_count: number;
    posts_count: number;
    liked_count: number;
    vote_count: number;
    design_count: number;
    nex_count: number;
    nex_by_me_count: number;
    nex_on_me_count: number;
  };
}

export interface LoginRequest {
  email: string;
  code: string;
}

export interface userInfo {
  token: string;
  user: User;
}

export interface GetCodeRequest {
  email: string;
}

export interface GetCodeResponse {
  code: string;
}

export interface RegisterRequest {
  username: string;
  email: string;
  password: string;
}

// 分页相关类型定义
export interface PaginationParams {
  page: number;
  pageSize: number;
}

export interface PaginationResponse<T> {
  list: T[];
  total: number;
  page: number;
  pageSize: number;
  totalPages: number;
}

// 商品相关类型定义
export interface Product {
  id: number;
  name: string;
  description: string;
  price: number;
  image: string;
  category: string;
  stock: number;
  createdAt: string;
  updatedAt: string;
}

export interface ProductListParams extends PaginationParams {
  category?: string;
  keyword?: string;
  minPrice?: number;
  maxPrice?: number;
}

// 订单相关类型定义
export interface Order {
  id: number;
  userId: number;
  products: OrderItem[];
  totalAmount: number;
  status: OrderStatus;
  shippingAddress: string;
  createdAt: string;
  updatedAt: string;
}

export interface OrderItem {
  productId: number;
  quantity: number;
  price: number;
}

export enum OrderStatus {
  PENDING = 'pending',
  PAID = 'paid',
  SHIPPED = 'shipped',
  DELIVERED = 'delivered',
  CANCELLED = 'cancelled',
}

// 通用响应类型
export interface ApiResponse<T = any> {
  code: number;
  message: string;
  data: T;
}

// 错误响应类型
export interface ApiError {
  code: number;
  message: string;
  details?: any;
}
